{include file="public/layout" /}
<body class="bodystyle" style="overflow-y: scroll; cursor: default; -moz-user-select: inherit; height: calc( 100% - 40px );">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="member/left" /}
<div class="page" style="min-width:auto;margin-left:100px;">
    <div class="flexigrid">
        <div class="mDiv pt0">
            {eq name="$Think.const.CONTROLLER_NAME.'@level_add'|is_check_access" value="1"}
            <div class="ftitle">
                <div class="fbutton" style="float: none;">
                    <a href="{:url('Level/level_add')}">
                        <div class="add">
                            <span><i class="layui-icon layui-icon-addition"></i>新增会员等级</span>
                        </div>
                    </a>
                </div>
            </div>
            {/eq}
            <!--<form class="navbar-form form-inline" id="searchForm" action="{:url('Level/level_index')}" method="get" onsubmit="layer_loading('正在处理');">-->
                <!--{$searchform.hidden|default=''}-->
                <!--<div class="sDiv">-->
                    <!--等级状态：-->
                    <!--<div class="sDiv2">-->
                        <!--<select name="status" class="select" style="margin:0 5px;">-->
                            <!--<option value="">全部</option>-->
                            <!--<option value="0" {eq name="$Request.param.status" value="0"}selected{/eq}>显示</option>-->
                            <!--<option value="1" {eq name="$Request.param.status" value="1"}selected{/eq}>隐藏</option>-->
                        <!--</select>-->
                    <!--</div>-->
                    <!--等级名称：-->
                    <!--<div class="sDiv2" style="margin: 0 6px;">-->
                        <!--<input type="text" size="30" name="keywords" value="{$Request.param.keywords}" class="qsbox" placeholder="关键词查询">-->
                    <!--</div>-->
                    <!--<input type="submit" class="layui-btn layui-btn-primary layui-border-blue layui-btn-xs" style="border-color: #3398cc;color: #3398cc;height: 26px;padding: 0 10px;" value="搜索">-->
                    <!--<input type="reset" class="layui-btn layui-btn-primary layui-border-blue layui-btn-xs" style="height: 26px;padding: 0 10px;" value="重置">-->

                <!--</div>-->
            <!--</form>-->
        </div>

        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                    <tr>
                        <th class="sign w20 none" axis="col0">
                            <div class="tc"></div>
                        </th>
                        <th abbr="article_show" axis="col5" class="w40">
                            <div class="tc">ID</div>
                        </th>
                        <th abbr="" axis="col6" class="w250">
                            <div class="text-l10">等级名称</div>
                        </th>
                        <th abbr="" axis="col4">
                            <div class="text-l10">等级说明</div>
                        </th>
                        <th abbr="" axis="col4" class="w80">
                            <div class="tc">包邮</div>
                        </th>
                        <th abbr="" axis="col4" class="w100">
                            <div class="tc">折扣率(%)</div>
                        </th>
                        <!--<th abbr="article_time" axis="col4" class="w100">-->
                            <!--<div class="tc">状态</div>-->
                        <!--</th>-->
                        <th axis="col1" class="w100">
                            <div class="tc">操作</div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto; min-height: auto;">
            <form id="PostForm">
                <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                    <table style="width: 100%">
                        <tbody id="Template">
                        {empty name="list"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <div class="no_row">
                                    <div class="no_pic"><img src="__SKIN__/images/null-data.png"></div>
                                </div>
                            </td>
                        </tr>
                        {else/}
                            {foreach name="list" item="vo" key="k" }
                            <tr class="tr">
                                <td class="sign none">
                                    <div class="w20 tc">
                                        <input type="hidden" name="level_id[]" value="{$vo.level_id}">
                                    </div>
                                </td>
                                <td class="sort">
                                    <div class="w40 tc">
                                        {$vo.level_id}
                                    </div>
                                </td>
                                <td>
                                    <div class="w250 text-l10">
                                        {$vo.level_name}
                                    </div>
                                </td>
                                <td style="width: 100%">
                                    <div class=" text-l10">
                                        {empty name="$vo.rights"}暂未填写{else/}{$vo.rights}{/empty}
                                    </div>
                                </td>
                                <td>
                                    <div class="w80 tc">
                                        {if condition="$vo['postage'] eq 1"}
                                            <span class="yes" onClick="changeTableVal('users_level', 'level_id', '{$vo.level_id}', 'postage', this);" data-yestext='<i class="fa fa-check-circle"></i>是' data-notext='<i class="fa fa-ban"></i>否'><i class="fa fa-check-circle"></i>是</span>
                                        {else /}
                                            <span class="no" onClick="changeTableVal('users_level', 'level_id', '{$vo.level_id}', 'postage', this);" data-yestext='<i class="fa fa-check-circle"></i>是' data-notext='<i class="fa fa-ban"></i>否'><i class="fa fa-ban"></i>否</span>
                                        {/if}
                                    </div>
                                </td>
                                <td>
                                    <div class="w100 tc">
                                        {$vo.discount}
                                    </div>
                                </td>
                                <!--<td>-->
                                    <!--<div class="w100 tc">-->
                                        <!--{if condition="$vo['status'] eq 1"}-->
                                        <!--<span class="yes" {eq name="$Think.const.CONTROLLER_NAME.'@level_edit'|is_check_access" value="1"} onClick="changeTableVal('users_level','level_id','{$vo.level_id}','status',this);" {/eq} ><i class="fa fa-check-circle"></i>是</span>-->
                                        <!--{else /}-->
                                        <!--<span class="no" {eq name="$Think.const.CONTROLLER_NAME.'@level_edit'|is_check_access" value="1"} onClick="changeTableVal('users_level','level_id','{$vo.level_id}','status',this);" {/eq} ><i class="fa fa-ban"></i>否</span>-->
                                        <!--{/if}-->
                                    <!--</div>-->
                                <!--</td>-->
                                <td  class="operation">
                                    <div class="w100 tc">
                                        {eq name="$Think.const.CONTROLLER_NAME.'@level_edit'|is_check_access" value="1"}
                                        <a href="{:url('Level/level_edit',array('level_id'=>$vo['level_id']))}" class="btn blue">编辑</a>
                                        {/eq}

                                        {eq name="$Think.const.CONTROLLER_NAME.'@del'|is_check_access" value="1"}
                                        <i></i>
                                        <a class="btn red" href="javascript:void(0);" data-url="{:url('Level/level_del')}" data-id="{$vo.level_id}" onClick="delfun(this);">
                                            删除
                                        </a>
                                        {/eq}
                                    </div>
                                </td>
                            </tr>
                            {/foreach}
                        {/empty}
                        </tbody>
                    </table>
                </div>
            </form>
            <div class="iDiv" style="display: none;"></div>
        </div>
        {notempty name="list"}
        <div class="tDiv">
            <div class="tDiv2">
                {include file="public/page" /}
            </div>
            <div style="clear:both"></div>
        </div>
        {/notempty}
    </div>
</div>
<script>
    $(document).ready(function(){
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });
    });

    // tr数,取唯一标识
    var tr_id = $('#Template .tr').length;

    function AddLevelType(){
        var isShowDownCount = {$isShowDownCount};
        var AddHtml = [];
        AddHtml += 
            '<tr class="tr" id="tr_'+tr_id+'">'+
                '<td class="sign none">'+
                    '<div class="w20 tc"><input type="hidden" name="level_id[]"></div>'+
                '</td>'+

                '<td style="width: 100%">'+
                    '<div style="padding-left: 10px;">'+
                        '<input type="text" name="level_name[]" class="w180">'+
                    '</div>'+
                '</td>'+

                '<td>'+
                    '<div class="w160 tc">'+
                        '<input type="text" name="level_value[]" onkeyup="this.value=this.value.replace(/[^0-9]/g,\'\')" class="tc w80">'+
                    '</div>'+
                '</td>';
        if (isShowDownCount == 1) {
            AddHtml += 
                '<td>'+
                    '<div class="w100 tc">'+
                        '<input type="text" name="down_count[]" class="tc w80" value="100">'+
                    '</div>'+
                '</td>';
        }
        AddHtml += 
                '<td>'+
                    '<div class="w160 tc">'+
                        '<input type="text" name="discount[]" class="tc w80" value="100">'+
                    '</div>'+
                '</td>'+

                '<td class="">'+
                    '<div class="w150 tc">'+
                        '<a class="btn red" href="javascript:void(0);" data-trid="tr_'+tr_id+'" onclick="DelHtml(this)"><i class="fa fa-trash-o"></i>删除</a>'+
                    '</div>'+
                '</td>'+
            '</tr>';
        $('#Template').append(AddHtml);
        tr_id += 1;
    }

    // 删除未保存的等级
    function DelHtml(obj){
        $('#'+$(obj).attr('data-trid')).remove();
    }

    // 提交
    function AddLevelData(obj){
        layer_loading('正在处理');
        $.ajax({
            type : 'post',
            url : $(obj).attr('data-url'),
            data : $('#PostForm').serialize(),
            dataType : 'json',
            success : function(data){
                layer.closeAll();
                if(data.code == 1){
                    layer.msg(data.msg, {icon: 1, time:1000},function(){
                        window.location.reload();
                    });
                }else{
                    layer.alert(data.msg, {icon: 2, title:false});
                }
            }
        })
    }

    // 删除
    function usersdel(obj){
        layer.confirm('确认彻底删除<span style="color:red;">'+$(obj).attr('data-level_name')+'</span>？', {
            shade: layer_shade,
            area: ['480px', '190px'],
            move: false,
            title: '提示',
            btnAlign:'r',
            closeBtn: 3,
            btn: ['确定','取消'] ,//按钮
            success: function () {
                  $(".layui-layer-content").css('text-align', 'left');
              }
        }, function(){
            layer_loading('正在处理');
            // 确定
            $.ajax({
                type : 'post',
                url : $(obj).attr('data-url'),
                data : {del_id:$(obj).attr('data-id'), _ajax:1},
                dataType : 'json',
                success : function(data){
                    layer.closeAll();
                    if(data.code == 1){
                        layer.msg(data.msg, {icon: 1});
                        window.location.reload();
                    }else{
                        layer.alert(data.msg, {icon: 2, title:false});
                    }
                }
            })
        }, function(index){
            layer.close(index);
        });
        return false;
    }
</script>

{include file="public/footer" /}